# -*- coding: utf-8 -*-
"""
author:码同学 极光
date:2023-01-16
desc: 
sample: 
"""
import os
import random
import re

import pytest

from util import getcsv_listdict, get_project_path


class TestSoapCase:

    def setup_class(self):
        print("setup_class")
    #
    # def teardown_class(self):
    #     print("teardown_class")

    def setup_method(self):
        phoneNumber = ["130", "131", "138", "145", "146", "147", "150", "151", "152", "172", "174", "175", "180", "181",
                       "182", "198"]
        phone = random.choice(phoneNumber) + str(random.randint(10000000, 99999999))
        self.testphone = phone
    #
    # def teardown_method(self):
    #     print("teardown---- teardown_method")

    @pytest.mark.parametrize("param", getcsv_listdict(os.path.join(get_project_path(),"files","sku.csv")))
    def test_code1(self,param):
        xml = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope ' \
              'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' \
              ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' \
              ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body>' \
              '<getMobileCodeInfoResponse xmlns="http://WebXml.com.cn/">' \
              f'<getMobileCodeInfoResult>{self.testphone}：北京 北京 北京移动全球通卡</getMobileCodeInfoResult>' \
              '</getMobileCodeInfoResponse></soap:Body></soap:Envelope>'
        # 分组技巧()
        r = '<getMobileCodeInfoResult>(.+)</getMobileCodeInfoResult>'
        result3 = re.findall(r, xml)  # list(list)
        print(result3)

